package org.platform.lwc.system.controller;

import lombok.extern.slf4j.Slf4j;
import org.platform.lwc.kafka.model.KafkaMessage;
import org.platform.lwc.kafka.service.KafkaMessageSender;
import org.platform.lwc.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * description: 生产者向kafka发送消息
 *
 * @author lwc
 * @date 2022/4/10
 */
@RestController
@Slf4j
@RequestMapping("/kafka")
public class ProducerController {
    @Autowired
    private KafkaMessageSender kafkaMessageSender;

    @GetMapping("/sendProduct")
    public R sendProductMsg() {
        KafkaMessage kafkaMessage = new KafkaMessage();
        kafkaMessage.setId(1L);
        kafkaMessage.setServiceId("productInfoService");
        kafkaMessageSender.sendMessage("demo-group",kafkaMessage);
        return R.success("ok");
    }

}

